#猜字游戏v1.0
import random

a = random.randint(1,10)
flag = True

while flag:
    b = int(input("在1-10之间输入一个你要猜的整数"))
    if b > a:
        print("大了")
    elif b < a:
        print("小了")
    else:
        print("恭喜猜中，本轮幸运数字：",a)
        break


#v2.0
import random


a = random.randint(1,10)
flag = True
money = 5000
print(a)
while flag:
    b = int(input("在1-10之间输入一个你要猜的整数"))
    if b > a:
        print("大了")
        money = money - 500
        if money <= 0:
            print("金币不足")
            flag = False
    elif b < a:
        print("小了")
        money = money - 500
        if money <= 0:
            print("金币不足")
            flag = False
    else:
        print("恭喜猜中，本轮幸运数字：",a)
        money = money + 3000
        flag = False
print(money)





#v3.0
import random

a = random.randint(1,10)
flag = True
money = 5000
print(a)
while flag:
    b = int(input("在1-10之间输入一个你要猜的整数"))
    if b > a:
        print("大了")
        money = money - 500
        if money <= 0:
            print("金币不足")
            flag = False
    elif b < a:
        print("小了")
        money = money - 500
        if money <= 0:
            print("金币不足")
            flag = False
    else:
        print("恭喜猜中，本轮幸运数字：", a)
        money = money + 3000
        flag1 = True
        while flag1:
            print("是否继续进行下一轮游戏？继续y，结束n")
            c = input()
            if c == "y":
                a = random.randint(1, 10)
                break
            elif c == "n":
                flag1 = False
                flag = False
            else:
                print("请输入y或者n")
                continue
print(money)

